-- TABLE 'ADDRESS'
IF OBJECT_ID('[Address]') IS NOT NULL
	DROP TABLE [Address]
CREATE TABLE [dbo].[Address](
	[AddressId] [int] IDENTITY(1,1) NOT NULL,	
	[TownId] [int] NULL,
	[Address][nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED 
(
	[AddressId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
-- TABLE 'TOWN'
IF OBJECT_ID('[Town]') IS NOT NULL
	DROP TABLE [Town]
CREATE TABLE [dbo].[Town](
	[TownId] [int] IDENTITY(1,1) NOT NULL,
	[CountyId] [int] NULL,
	[TownName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Town] PRIMARY KEY CLUSTERED 
(
	[TownId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
--TABLE 'COUNTY'
IF OBJECT_ID('[County]') IS NOT NULL
	DROP TABLE [County]
CREATE TABLE [dbo].[County](
	[CountyId] [int] IDENTITY(1,1) NOT NULL,
	[Postcode] [int] NULL,
	[CountryId] [int] NULL,
	[CountyName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_County] PRIMARY KEY CLUSTERED 
(
	[CountyId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
--TABLE 'COUNTRY'
IF OBJECT_ID('[Country]') IS NOT NULL
	DROP TABLE [Country]
CREATE TABLE [dbo].[Country](
	[CountryId] [int] IDENTITY(1,1) NOT NULL,
	[CountryName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Country] PRIMARY KEY CLUSTERED 
(
	[CountryId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
--TypeOfBusiness
IF OBJECT_ID('[TypeOfBusiness]') IS NOT NULL
	DROP TABLE [TypeOfBusiness]
CREATE TABLE [dbo].[TypeOfBusiness](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[SicCode] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[TypeName] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
-- Organisations
IF OBJECT_ID('[Organisations]') IS NOT NULL
	DROP TABLE [Organisations]
	CREATE TABLE [dbo].[Organisations](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ShortDesc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ContactID] [int] NOT NULL,
	[Addr1] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Addr2] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Addr3] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[City] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[County] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Country] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PreferredOrg] [bit] NULL,
	[ExpOfInterest] [bit] NULL,
	[TypeOfBusinessId] [int] NOT NULL,
	[FullDesc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PhoneNumber] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Fax] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Email] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[WebAddr] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CharityNumber] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CompanyNumber] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[OrgSpecicalism] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ServiceDisCap] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ServiceBarCap] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ServiceBenCap] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ServicePerCirCap] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ServiceEthCap] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Accreditation] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EOIProgramme] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EOIService] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[GovOffRegionID] [int] NOT NULL,
	[TrustRegionID] [int] NOT NULL,
	[TrustDistrictID] [int] NOT NULL,
	[PostCode] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[IsActive] [bit] NOT NULL CONSTRAINT [DF_Organisation_IsActive]  DEFAULT ((1)),
 CONSTRAINT [PK_Organisation] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO